package org.mozhu.mboot.core.web;

import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.ServletWebRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class RequestContextHolder {
    public static HttpServletRequest getRequest() {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) org.springframework.web.context.request.RequestContextHolder.getRequestAttributes();
        return servletRequestAttributes == null ? null : servletRequestAttributes.getRequest();
    }

    public static HttpServletResponse getResponse() {
        ServletWebRequest servletWebRequest = (ServletWebRequest) org.springframework.web.context.request.RequestContextHolder.getRequestAttributes();
        return servletWebRequest == null ? null : servletWebRequest.getResponse();
    }
}
